package com.gyg.程序员面试金典;

import java.util.Arrays;

/**
 * 面试题 01.02. 判定是否互为字符重排
 */
public class T01_02 {
    /**
     * 面试题 01.02. 判定是否互为字符重排
     *
     * @param s1
     * @param s2
     * @return
     */
    public boolean CheckPermutation(String s1, String s2) {
        if (s1.length() != s2.length()) {
            return false;
        } else {
            char[] chars1 = s1.toCharArray();
            Arrays.sort(chars1);
            String s_s1 = Arrays.toString(chars1);

            char[] chars2 = s2.toCharArray();
            Arrays.sort(chars2);
            String s_s2 = Arrays.toString(chars2);
            if (s_s2.equals(s_s1)) {
                return true;
            }
        }
        return false;
    }

}
